import Mock from 'mockjs'
import setupMock, { successResponseWrap } from '@/utils/setup-mock'
import { AUTH_MENU_LIST } from '@/config/api'
import { IAuthMenu } from '@/types/auth/menu'

setupMock({
    setup() {
        // 用户的服务端菜单
        Mock.mock(new RegExp(AUTH_MENU_LIST), () => {
            const menuList: Omit<IAuthMenu, '_protect'>[] = [
                {
                    id: 1,
                    pid: undefined,
                    title: '首页',
                    path: 'home',
                    hidden: 0,
                    sort: 1,
                    active: '',
                    ignore_cache: 0,
                    component: '/home/index.vue',
                    icon: 'HomeOutlined'
                },

                {
                    id: 2,
                    pid: undefined,
                    title: '权限管理',
                    path: 'auth',
                    hidden: 0,
                    sort: 2,
                    active: '',
                    ignore_cache: 0,
                    component: ''
                },
                {
                    id: 3,
                    pid: 2,
                    title: '用户',
                    path: 'user',
                    hidden: 0,
                    sort: 1,
                    active: '',
                    ignore_cache: 0,
                    component: '/auth/user/index.vue'
                },
                {
                    id: 4,
                    pid: 2,
                    title: '角色',
                    path: 'role',
                    hidden: 0,
                    sort: 1,
                    active: '',
                    ignore_cache: 0,
                    component: '/auth/role/index.vue'
                },
                {
                    id: 5,
                    pid: 2,
                    title: '菜单',
                    path: 'menu',
                    hidden: 0,
                    sort: 1,
                    active: '',
                    ignore_cache: 0,
                    component: '/auth/menu/index.vue'
                },

                {
                    id: 30,
                    pid: undefined,
                    title: '开放数据',
                    path: 'core',
                    hidden: 0,
                    sort: 1,
                    active: '',
                    ignore_cache: 0,
                    component: '',
                    icon: 'ConsoleSqlOutlined'
                },
                {
                    id: 31,
                    pid: 30,
                    title: '应用管理',
                    path: 'app',
                    hidden: 0,
                    sort: 1,
                    active: '',
                    ignore_cache: 0,
                    component: '/core/app/index.vue',
                    icon: ''
                },
                {
                    id: 311,
                    pid: 31,
                    title: '应用配置',
                    path: ':id',
                    hidden: 1,
                    sort: 1,
                    active: 'core-app',
                    ignore_cache: 0,
                    component: '/core/app/home.vue',
                    icon: ''
                },
                {
                    id: 33,
                    pid: 30,
                    title: '接口分组',
                    path: 'group',
                    hidden: 0,
                    sort: 1,
                    active: '',
                    ignore_cache: 0,
                    component: '/core/group/index.vue',
                    icon: ''
                },
                {
                    id: 32,
                    pid: 30,
                    title: '验证规则',
                    path: 'rule',
                    hidden: 0,
                    sort: 1,
                    active: '',
                    ignore_cache: 0,
                    component: '/core/rule/index.vue',
                    icon: ''
                }
            ]
            return successResponseWrap(menuList)
        })
    }
})
